﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <script>
        /*
            100 内的整数求和
            1 + 2 + 3 + 4 + 5 + 。。。 + 100
            sum = 1 + 2
            sum + 3
            sum + 4 ...
            1. 遍历 1 - 100
            2. 声明一个变量保存求和
            3. 累加
        */
        let sum = 0;
        //for (var i = 0; i < 101; i++) {
        //    sum = sum + i;

        //}
        //console.log(sum);
        for (var i = 100; i > 0; i--) {
            sum = sum + i;
        } console.log(sum);
    </script>
</body>
</html>